package com.chang.member.web;

import com.chang.common.utils.R;
import com.chang.member.feign.OrderFeignClient;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: changzhenxi
 * @date: 2025年03月27日 10:18
 * @Version: 1.0
 * @description:
 */
@Controller
public class MemberWebController {

    @Resource
    OrderFeignClient orderFeignClient;

    @GetMapping(value = "alipay/return")
    public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model) {
        // 获取支付宝传递的所有请求数据

        // 查出当前登录用户的所有订单数据
        Map<String, Object> page = new HashMap<>();
        page.put("pageNum", pageNum.toString());
        R result = orderFeignClient.listWithItem(page);
        // 将数据放到请求域
        model.addAttribute("orders", result);
        return "orderList";
    }

}
